package com.axcbd.demo.controller;


import com.axcbd.demo.dto.response.ApiResponse;
import com.axcbd.demo.model.CameraInformation;
import com.axcbd.demo.service.CameraInformationService;
import jakarta.xml.ws.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/CameraInformation")
public class CameraInformationController {

    @Autowired
    CameraInformationService cameraInformationService;

    @GetMapping("/getInformation")
    public ResponseEntity<ApiResponse<?>> getAllCameraInformation(@RequestParam int cameraid){
        List<CameraInformation> informations = cameraInformationService.getCameraInformationByCameraid(cameraid);
        return ResponseEntity.ok(new ApiResponse<>(informations));
    }

    @GetMapping("/getInformationByDate")
    public ResponseEntity<ApiResponse<?>> getCameraInformationByDate(@RequestParam int cameraid, @RequestParam String date) throws ParseException {
        List<CameraInformation> informations = cameraInformationService.getCameraInformationByDateRange(cameraid,date);
        return ResponseEntity.ok(new ApiResponse<>(informations));
    }
}
